package com.yootk.servlet;

import com.yootk.common.util.ParameterUtil;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/upload.action")
public class UploadServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=UTF-8");
        ParameterUtil parameterUtil = new ParameterUtil(req);
        String param = parameterUtil.getParameter("message"); // 参数名称为msg
        resp.getWriter().println("<h1>message = " + param + "</h1>");
        resp.getWriter().println("<h1>photo = " + parameterUtil.getParameter("photo") + "</h1>");
    }
}
